/********************************************
 * 
 * 타이틀 : 순위 표시 화면
 * 기능 : 
 * 작성자 : LJI
 * 작성일 : 2013.09.26
 * 
 ********************************************/

package com.game.pacman.client;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;


public class RankScreen extends JPanel{
	private JLabel labelTitle;
	private JButton buttonExit;
	private Image imageBack;
	private Image imageButton;
	
	public RankScreen(Image imageBack,Image imageButton) {
		this.imageBack=imageBack;
		this.imageButton=imageButton;
		init();
	}

	public void init(){
		setLayout(null);

		//타이틀 표시
		labelTitle=new JLabel();
		labelTitle.setText("Rank");

		labelTitle.setBounds(
			(Constants.WINDOW_WIDTH-Constants.BUTTON_WIDTH)/2,
			10,
			Constants.BUTTON_WIDTH,
			Constants.BUTTON_HEIGHT);
		
		add(labelTitle);
		
		//처음으로 버튼
		buttonExit = new JButton();
		buttonExit.setBounds(
				(Constants.WINDOW_WIDTH-Constants.BUTTON_WIDTH)-Constants.gap,
				Constants.WINDOW_HEIGHT-Constants.BUTTON_HEIGHT-Constants.gap,
				Constants.BUTTON_WIDTH,
				Constants.BUTTON_HEIGHT);
		
		buttonExit.setBackground(Color.white);
		buttonExit.setOpaque(false);  //투명하게
		buttonExit.setBorderPainted(false);
		
		buttonExit.setIcon(new ImageIcon(imageButton));
		buttonExit.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				setFocusable(false);
				GameFrame.card.show(GameFrame.mainScreen, Constants.MENU_SCREEN);
			}
		});
		
		add(buttonExit);
	}

	//배경이미지 표시
	@Override
	public void paint(Graphics g) {
		g.drawImage(imageBack,0, 0,null);
		setOpaque(false);
		super.paint(g);
	}	
}
